<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>学生云系统登录</title>
<link rel="stylesheet" type="text/css" href="dist/semantic.min.css">
<link rel="stylesheet" type="text/css" href="dist/dropdown.min.css">
<script src="assets/script/jquery.min.js"></script>
<script src="assets/script/stucloud.js"></script>
<script src="dist/semantic.min.js"></script>
<script src="dist/dropdown.min.js"></script>
<script src="assets/script/jquery.form.js"></script>
</head>
<body>
	<style type="text/css">
body {
	background-color: #DADADA;
}

body>.grid {
	height: 100%;
}

.image {
	margin-top: 0px;
}

.column {
	max-width: 600px;
}

@media screen and (max-width: 600px) {
	.column {
		max-width: 90% !important;
		padding-top: 0px !important;
		padding-left: 0px !important;
		padding-right: 0px !important;
		padding-bottom: 0px !important;
	}
	.stumain {
		margin-top: 0px !important;
		margin-right: 0px !important;
		margin-left: 0px !important;
		margin-bottom: 0px !important;
	}
}
</style>
	<script type="text/javascript">
	function onSuccess(data){
		console.log(data);
		if (data.code==0||data.code==3) {
			window.location.href = "index.php";
			return;
		}else{
			showMessage("backMessage",data.code,"登录失败，服务器返回:" + data.message);
			$("#loginform").addClass("error").removeClass("success");
		}
	}
	function onError(data){
		showMessage("backMessage",-101,"登录失败，服务器返回未知数据，详情请见console  code:-101");
		$("#loginform").addClass("error").removeClass("success");
		console.log(data);
	}
	$(document).ready(function() {
		$('.ui.form').form({
			fields: {
				account: {
					identifier: 'account',
					rules: [{
						type: 'empty',
						prompt: '账户不能为空'
					}]
				},
				passwd: {
					identifier: 'passwd',
					rules: [{
						type: 'minLength[6]',
						prompt: '密码必须大于六位'
					},
					{
						type: 'empty',
						prompt: '密码不能为空'
					}]
				}
			}
		});
		bindAjaxForm($("#loginform"),onSuccess,onError,"dimmer");
		
	});
</script>
	<div class="ui middle aligned center aligned grid stumain">
		<div class="column">
			<form class="ui form" id="loginform" url="index.php?mod=login&op=login&ajax=true">
				<input type="hidden" name="op" value="login"> <input type="hidden" name="mod" value="login">
				<div class="ui attached message">
					<h2 class="ui image header">学生云系统</h2>
					<br />
					<div class="header">欢迎来到StuCloud</div>
					<?php global $tip;if($tip==1){?>
					<p>进行这项操作前，你必须登录</p>
					<?php
} else {if ($tip == 2) {?>
					<p>注册成功，请登录</p>
					<?php }else{?>
						<p>请填写信息以登录</p><?php }}?>
					没有账户？<a href="index.php?mod=register">点击注册;</a>
				</div>
				<div class="ui stacked attached segment">
					<div class="ui dimmer" id="dimmer">
						<div class="ui text loader">登录中</div>
					</div>
					<br />
					<div class="field">
						<div class="ui left icon input">
							<i class="mail icon"></i> <input type="text" name="account" placeholder="uid/手机号/电子邮件地址">
						</div>
					</div>
					<div class="field">
						<div class="ui left icon input">
							<i class="lock icon"></i> <input type="password" name="passwd" placeholder="密码">
						</div>
					</div>
					<div class="ui fluid large submit button">登录</div>
				</div>
				<div class="ui error message" id="backMessage"></div>
			</form>
		</div>
	</div>
</body>
</html>
